home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 41.zip / BS1 part 41 / Lattice C v5.02 d4.adf / examples / ftoc.c < prev    next >
C/C++ Source or Header  |  1988-11-07  |  503b  |  22 lines

  1.   /* print Fahrenheit-Celsius table
  2.     for f = 0, 20, ..., 300  
  3.     (This program is from p. 8 of the Kernighan and Ritchie text) 
  4.     */
  5. int lower, upper, step;
  6. float fahr, celsius;
  7.  
  8. main()
  9. {
  10.  
  11.     lower = 0;         /* lower limit of temperature table */
  12.     upper = 300;       /* upper limit */
  13.     step = 20;         /* step size */
  14.  
  15.     fahr = lower;
  16.     while (fahr <= upper) {
  17.         celsius = (5.0/9.0) * (fahr-32.0);
  18.         printf("%4.0f %6.1f\n", fahr, celsius);
  19.         fahr = fahr + step;
  20.     }
  21. }
  22.